#region File Description
//-----------------------------------------------------------------------------
// Game.cs
//
// Microsoft XNA Community Game Platform
// Copyright (C) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#endregion

#region Using Statements
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using AwesomeTanks.Sources;
using AwesomeTanks.Sources.Screens;
using AwesomeTanks.Sources.ScreenManagement;
using System.Collections.Generic;
using AwesomeTanks.Sources.GameElements;
using AwesomeTanks.Sources.Media;
using Bloom;
//using AwesomeTanks.Sources.Particles;
#endregion

namespace AwesomeTanks
{

    /* Developers :
     * Anthony 
     * Hugo
     * Pierre
     * Alexandre     
     * Mathieu
     */

    /// <summary>
    /// Sample showing how to manage different game states, with transitions
    /// between menu screens, a loading screen, the game itself, and a pause
    /// menu. This main game class is extremely simple: all the interesting
    /// stuff happens in the ScreenManager component.
    /// </summary>
    public class GameStateManagementGame : Microsoft.Xna.Framework.Game
    {
        #region Fields

        /// <summary>
        /// The width of the screen in portrait mode, in pixel.
        /// </summary>
        public const int DEFAULT_PORTRAIT_SCREEN_WIDTH = 1920;
        /// <summary>
        /// The height of the screen in portrait mode, in pixel.
        /// </summary>
        public const int DEFAULT_PORTRAIT_SCREEN_HEIGHT = 1080;
        /// <summary>
        /// 

        /// <summary>
        /// The width of the screen in portrait mode, in pixel.
        /// </summary>
        public const int DEBUG_PORTRAIT_SCREEN_WIDTH = 1600;
        /// <summary>
        /// The height of the screen in portrait mode, in pixel.
        /// </summary>
        public const int DEBUG_PORTRAIT_SCREEN_HEIGHT = 800;
        /// <summary>
        /// 

        public static GameStateManagementGame Instance { get; private set; }
        public static Viewport Viewport { get { return Instance.GraphicsDevice.Viewport; } }
        public static Vector2 ScreenSize { get { return new Vector2(Viewport.Width, Viewport.Height); } }
        
        //public static ParticleManager<ParticleState> ParticleManager { get; private set; }

        GraphicsDeviceManager graphics;
        ScreenManager screenManager;
        public static BloomComponent bloom;

        // By preloading any assets used by UI rendering, we avoid framerate glitches
        // when they suddenly need to be loaded in the middle of a menu transition.
        static readonly string[] preloadAssets =
        {
            @"Menus/Textures2D/gradient",
        };


        #endregion

        #region Initialization


        /// <summary>
        /// The main game constructor.
        /// </summary>
        public GameStateManagementGame()
        {
            Instance = this;

            Content.RootDirectory = "Content";

            graphics = new GraphicsDeviceManager(this);
            graphics.PreferredBackBufferWidth = DEFAULT_PORTRAIT_SCREEN_WIDTH;
            graphics.PreferredBackBufferHeight = DEFAULT_PORTRAIT_SCREEN_HEIGHT;
            graphics.IsFullScreen = true;            

            // Create the screen manager component.
            screenManager = new ScreenManager(this);

            Components.Add(screenManager);
            bloom = new BloomComponent(this);
            Components.Add(bloom);
            bloom.Settings = BloomSettings.PresetSettings[5];
            //bloom.Settings = new BloomSettings(null, 0.25f, 4, 2, 1, 1.5f, 1);

            Sound.Load(Content);
            
            // Activate the first screens.
            screenManager.AddScreen(new BackgroundScreen(Art.TITLE_BACKGROUND_PATH), null);
            screenManager.AddScreen(new TitleScreen(), null);

            
        }


        /// <summary>
        /// Loads graphics content.
        /// </summary>
        protected override void LoadContent()
        {
            Art.Load(Content);

            foreach (string asset in preloadAssets)
            {
                Content.Load<object>(asset);
            }
        }


        #endregion

        #region Draw


        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        protected override void Draw(GameTime gameTime)
        {            
            bloom.BeginDraw();             
            graphics.GraphicsDevice.Clear(Color.Black);
            base.Draw(gameTime);           
        }


        #endregion
    }


    #region Entry Point

    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    static class Program
    {
        static void Main()
        {
            using (GameStateManagementGame game = new GameStateManagementGame())
            {
                game.Run();
            }
        }
    }

    #endregion
}
